﻿
import QtQuick 2.2
import QtQuick.Controls 1.2
import QtQuick.Controls.Private 1.0
import QtQuick.Window 2.0
Style {
    id: styleitem

    //Slider 附加到style上
//    readonly property Slider control: __control
     readonly property SliderMy control: __control
//    padding { top: 0 ; left: 0 ; right: 0 ; bottom: 0 }

         padding { top: 0 ; left: 0 ; right: 0 ; bottom: 0 }

//    //获取全屏参数
//    property double m_width:Screen.width/1920
//    property double m_height:Screen.height/1080
    signal openssSliver()
//    此属性保存滑块句柄的项。
//    可以通过 控件属性访问滑块。
    //滑块
    property Component handle: Item{
            width: movePoint.width
            height:  movePoint.height
            anchors.bottom: parent.bottom
//            anchors.bottomMargin: 6
            Image
            {
                id:movePoint
                source:"./切图/时间轴/滑块.png"
//                width: 58 *m_width
//                height:48 *m_height
                width: 58 *m_width
                height:48
                Text
                {
                    anchors.verticalCenter: parent.verticalCenter
                    anchors.horizontalCenter: parent.horizontalCenter
                    anchors.verticalCenterOffset: -2

                    text:
                    {
//                        暂时屏蔽
                        if (endHourTimeStr.length ===0)
                        {

                            return ""
                        }else
                        {
                             if(control.value >5.99)
                             {
                                  return endHourTimeStr[6]
                             }else
                             {
                                 return endHourTimeStr[parseInt(control.value)]
                             }


                        }
                    }
                    color: "white"
                    font.pixelSize:12*m_pixRatio
                }
            }

    }
    //底子
    property Component groove: Item {
//        property color fillColor: "#49d"
        //anchors.verticalCenter: parent.verticalCenter
//        implicitWidth: Math.round(TextSingleton.implicitHeight * 4.5)
//        implicitHeight: Math.max(6, Math.round(TextSingleton.implicitHeight * 0.3))
//        anchors.bottom: parent.top
//        anchors.bottomMargin: 10
        width:bg.width
        height: bg.height
        Image
        {
            id:bg
            source: "./切图/时间轴/新时间轴.png"
//            width: 1750 *m_width
//            height:39 *m_height
         //  width: 1750 *m_width
		 width:Screen.width - 170
//            height:39
             height:39
        }


    }

    /*! This property holds the tick mark labels
        \since QtQuick.Controls.Styles 1.1

        You can access the handle width through the \c styleData.handleWidth property.
    */
    property Component tickmarks: Repeater {
        id: repeater
//        model: control.stepSize > 0 ? 1 + (control.maximumValue - control.minimumValue) / control.stepSize : 0
//        model:  24
        model:7
        Rectangle {
            id:zzz
            color: "transparent"
            width: 1 ; height: 1
            x: styleData.handleWidth / 2 + index * ((repeater.width - styleData.handleWidth) / (repeater.count-1))
            Text {

                 color: "white"
                anchors.verticalCenter: parent.verticalCenter
                anchors.horizontalCenter: parent.horizontalCenter
                anchors.verticalCenterOffset: 8
                transform: Scale { origin.x: 0; origin.y: 0; xScale: 1.5;yScale: 1.5}
//                transform: Scale { origin.x: 0; origin.y: 0; xScale: 1.0;yScale: 1.0}
                 text:{
                     //暂时屏蔽

                     if (endMothTimeStr.length ===0)
                     {
                         return ""
                     }else
                     {
                         return endMothTimeStr[index]
                     }
                 }
                 font.pixelSize: 12 *m_pixRatio
            }

        }


    }

    /*! This property holds the slider style panel.

        Note that it is generally not recommended to override this.
    */
    property Component panel: Item {
        id: root
        property int handleWidth: handleLoader.width
        property int handleHeight: handleLoader.height

        property bool horizontal : control.orientation === Qt.Horizontal
        property int horizontalSize: grooveLoader.implicitWidth + padding.left + padding.right
        property int verticalSize: Math.max(handleLoader.implicitHeight, grooveLoader.implicitHeight) + padding.top + padding.bottom

        implicitWidth: horizontal ? horizontalSize : verticalSize
        implicitHeight: horizontal ? verticalSize : horizontalSize

        y: horizontal ? 0 : height
        rotation: horizontal ? 0 : -90
        transformOrigin: Item.TopLeft
         readonly property int endTimeStr: control.endTimeStr
         readonly property var endMothTimeStr: control.endMothTimeStr
         readonly property var endHourTimeStr: control.endHourTimeStr
        Item {
            id:root02
            anchors.fill: parent

            Loader {
                id: grooveLoader
                property QtObject styleData: QtObject {
                    readonly property int handlePosition: handleLoader.x + handleLoader.width/2
                    readonly property var endMothTimeStr: control.endMothTimeStr
                }
               // x: padding.left
                sourceComponent: groove
                width: (horizontal ? parent.width : parent.height) - padding.left - padding.right
//                y:  Math.round(padding.top + (Math.round(horizontal ? parent.height : parent.width - padding.top - padding.bottom) - grooveLoader.item.height)/2)
               // y : handleLoader.y +10.5
            }
            Loader {
                id: tickMarkLoader
                anchors.fill: parent
                sourceComponent: control.tickmarksEnabled ? tickmarks : null
                property QtObject styleData: QtObject {
                    readonly property int handleWidth: control.__panel.handleWidth
                }

            }
            Loader {
                id: handleLoader
                sourceComponent: handle
               // anchors.bottom: grooveLoader.bottom
                anchors.verticalCenter: grooveLoader.verticalCenter
                x: Math.round((control.__handlePos - control.minimumValue) / (control.maximumValue - control.minimumValue) * ((horizontal ? root.width : root.height) - item.width))
            }
        }
    }

}
